chars = []
with open("p059_cipher.txt","r") as f:
    temp =  f.read()
    chars = temp.split(",")
# print chars

num = []
for c in chars:
    num.append(int(c))
# print num
msg = []
key = []
for a in range(97,123):
    for b in range(97,123):
        for c in range(97,123):
            key.append(a)
            key.append(b)
            key.append(c)
            for i in range(len(num)):
                temp = num[i] ^ key[i % 3]
                msg.append(temp)

            allstr = "".join([chr(tempa) for tempa in msg])   
            
            if "the" in allstr and "and" in allstr and "to" in allstr and "that" in allstr:
                print chr(key[0]),chr(key[1]),chr(key[2]),sum(msg)
                print allstr 

            key = []
            msg = []
print "ok"